<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"content="width=device-width, initialscale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <form action="save" v-on:submit.prevent = "onSubmitForm()">
            <input type="text" name="input" id="inputid" v-model="user.name"/>
            <button type="submit">保存</button>
        </form>
    </div>
    <script src="vue.min.js"></script>
        <script>
            new Vue({
                el: '#app',
                data: {
                    user:{
                        name:"zhangsan",
                        age: "20"
                    }
                },
                methods: {
                    onSubmitForm() {
                        if(this.user.name) { // 有值为true
                            console.log('execute onSubmitForm ... ')
                        } else {
                            alert('输入用户名 ... ')
                        }
                    }
                }
            })
        </script>
</body>

</html>